bugfix(supply): Implement proportional supply bonus scaling to fix too generous money deposits for partial supply drops#2431
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SupplyTruckAIUpdate.h | Adds getMaxBoxes() pure virtual to SupplyTruckAIInterface and a concrete implementation in SupplyTruckAIUpdate that reads m_maxBoxesData; ChinookAIUpdate inherits the implementation correctly via SupplyTruckAIUpdateModuleData. No issues. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WorkerAIUpdate.h | Implements the new getMaxBoxes() virtual method by reading m_maxBoxesData from WorkerAIUpdateModuleData; consistent with the SupplyTruckAIUpdate counterpart. No issues. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp | Extracts upgrade-boost calculation into getUpgradedSupplyBoostValue, guards against division-by-zero via maxBoxes > 0, and snapshots box count before unloading for correct proportional scaling; one minor concern around deliveredBoxes > maxBoxes edge case and existing integer-truncation issue (discussed in prior thread). |
Sequence Diagram
sequenceDiagram
participant Truck as SupplyTruck / Worker / Chinook
participant Dock as SupplyCenterDockUpdate::action
participant AI as SupplyTruckAIInterface
Dock->>AI: getUpgradedSupplyBoostValue()
activate AI
Note over AI: #if RETAIL_COMPATIBLE_CRC → full boost (unscaled)
AI->>AI: getMaxBoxes() → maxBoxes
alt maxBoxes > 0
AI->>AI: getUpgradedSupplyBoost() → boost
AI->>AI: getNumberBoxes() → deliveredBoxes
AI-->>Dock: (boost × deliveredBoxes) / maxBoxes
else maxBoxes == 0
AI-->>Dock: 0
end
deactivate AI
loop while loseOneBox() returns true
Dock->>AI: loseOneBox()
Dock->>Dock: value += getSupplyBoxValue()
end
Dock->>Dock: value += scaledBoost
Dock->>Dock: deposit(value) → player money
Last reviewed commit: 378bea0
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
7bfc70d to
0f2e2bf
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
| Int maxBoxes = supplyTruckAI->getMaxBoxes(); | ||
| if( maxBoxes > 0 ) | ||
| { | ||
| value += upgradedSupplyBoost * deliveredBoxes / maxBoxes; // Intentional integer truncation. |
There was a problem hiding this comment.
Is the idea that the supply boost is only applied up to maxBoxes?
So if we have a limit of 5 boxes but we deliver 7? we should only be applying the boost to 5 boxes?
Since the above will be under valuing the bonus if so.
There was a problem hiding this comment.
Nvm i misunderstood what it was doing.
But if max boxes is zero then should we be giving any kind of bonus since shouldn't it technically not be able to carry anything?
There was a problem hiding this comment.
Good point - units with maxBoxes 0 have no business docking supplies anyways.
0f2e2bf to
b87de30
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
e3eadf6 to
bab6097
Compare
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SupplyTruckAIUpdate.h
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
|
Is this Zero Hour only? |
No Supply Lines upgrade in Generals, only in ZH. |
824e79e to
bb5a635
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
bb5a635 to
67212ba
Compare
|
This needs rebase. |
Signed-off-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
67212ba to
378bea0
Compare
Resolves USA Chinook extra money drop is always 60$ no matter how big the base money load is #132
Added a new
getMaxBoxes()method toSupplyTruckAIInterfaceand implemented it in bothSupplyTruckAIUpdateandWorkerAIUpdateto expose the configured maximum box capacity.Updated
SupplyCenterDockUpdate::actionto snapshot the box count before unloading and scale the upgrade bonus proportionally to the delivered cargo.